<?php
declare (strict_types = 1);

namespace test\util;

use app\admin\controller\Index;
use app\admin\model\AdminModel;
use util\ClassAttrParser;
use tp6test\FrameworkTestCase;

/**
 * php think test --filter ClassAttrParserTest::testParseProperties
 */
class ClassAttrParserTest extends FrameworkTestCase {
    
    public function testParseMeta() {
        $class = AdminModel::class;
        $parser = ClassAttrParser::parser($class);
        $table = $parser->getMetaAttr('Table');
        $this->assertEquals('tl_admin', $table);
    }
    
    public function testParseProperties() {
        $class = AdminModel::class;
        $parser = ClassAttrParser::parser($class);
        $properties = $parser->parseProperties();
        $this->assertTrue(true);
    }
    
    public function testParseStaticProperties() {
        $class = AdminModel::class;
        $parser = ClassAttrParser::parser($class);
        $properties = $parser->parseStaticProperties();
        $this->assertTrue(true);
    }
    
    public function testParseConstants() {
        $class = AdminModel::class;
        $parser = ClassAttrParser::parser($class);
        $properties = $parser->parseConstants();
        $this->assertTrue(count($properties) > 0);
    }
    
    public function testParseMethods() {
        $class = Index::class;
        $parser = ClassAttrParser::parser($class);
        $methods = $parser->parseMethodAttrs('login');
        $this->assertTrue(isset($methods['NoLogin']));
    }
}
